<template>
	<view class="container">
		<view class="form">
			<text class="title">登录</text>
			<input class="input" placeholder="请输入用户名" />
			<input class=" input" placeholder="请输入密码" />
			<button class=" btn" type="primary" @click="handleLogin">登录</button>
			<view class="link">
				<text>没有账号？</text>
				<navigator url="/pages/Register/Register">去注册</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: 'jqf',
				password: '123456',
				isPwdfocus: false
			}
		},
		methods: {
			handleLogin() {
				if (!this.username || !this.password) {
					uni.showToast({
						title: '请输入完整信息',
						icon: 'none'
					})
					return
				}
				if (this.username === 'jqf' && this.password === '123456') {
					uni.showLoading({
						title: '登录中...'
					})

					setTimeout(() => {
						uni.hideLoading()
						uni.showToast({
							title: '登录成功'
						})
						uni.switchTab({
							url: "/pages/tabBar/api/api"
						})
					}, 1000)
				} else {
					uni.showToast({
						title: '密码错误， 请重新输入'
					});
					this.password = '';
					this.isPwdfocus = true;
				}

			}
		}
	}
</script>

<style>
	.container {
		/* 页面容器样式 */
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		min-height: 100vh;
		background-color: #f5f5f5;
		padding: 0 30rpx;
	}

	.form {
		/* 表单容器样式 */
		width: 100%;
		max-width: 500rpx;
		background-color: #ffffff;
		padding: 60rpx 40rpx;
		border-radius: 20rpx;
		box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
	}

	.title {
		/* 标题样式 */
		display: block;
		text-align: center;
		font-size: 40rpx;
		font-weight: bold;
		color: #333333;
		margin-bottom: 60rpx;
	}

	.input {
		/* 输入框样式 */
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		padding: 0 20rpx;
		margin-bottom: 30rpx;
		border: 2rpx solid #eeeeee;
		border-radius: 10rpx;
		font-size: 28rpx;
		box-sizing: border-box;
	}

	.input:focus {
		/* 输入框聚焦样式 */
		border-color: #007aff;
		outline: none;
	}

	.btn {
		/* 按钮样式 */
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		font-size: 30rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}

	.link {
		/* 链接区域样式 */
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 40rpx;
		font-size: 26rpx;
		color: #666666;
	}

	.link navigator {
		/* 注册链接样式 */
		color: #007aff;
		margin-left: 10rpx;
		text-decoration: none;
	}
</style>